package org.breathe.command.impl.ping;

import org.breathe.command.Command;
import org.breathe.command.CommandType;
import org.breathe.protocal.Resp;
import org.breathe.protocal.decode.BulkString;
import org.breathe.protocal.decode.RespArray;
import org.breathe.protocal.decode.RespInteger;
import org.breathe.server.core.RedisCore;

import static org.breathe.protocal.decode.BulkString.EMPTY_BYTES;

/**
 * @author: breathe
 * @createTime: 2025-06-09
 */
public class Hello implements Command {
    private RedisCore redisCore;
    public Hello(RedisCore redisCore) {
        this.redisCore = redisCore;
    }
    @Override
    public CommandType getType() {
        return CommandType.HELLO;
    }

    @Override
    public void setContext(Resp[] array) {

    }

    @Override
    public Resp handle() {
        Resp[] content = new Resp[14];
        content[0] = new BulkString("server");
        content[1] = new BulkString("redis");
        content[2] = new BulkString("version");
        content[3] = new BulkString("6.2.18");
        content[4] = new BulkString("proto");
        content[5] = new RespInteger(2);
        content[6] = new BulkString("id");
        content[7] = new RespInteger(3);
        content[8] = new BulkString("mode");
        content[9] = new BulkString("standalone");
        content[10] = new BulkString("role");
        content[11] = new BulkString("master");
        content[12] = new BulkString("modules");
        content[13] = new BulkString(EMPTY_BYTES);
        RespArray respArray = new RespArray(content);
        return respArray;
    }

    @Override
    public boolean writeCommand() {
        return false;
    }
}
